package ch2;

import java.util.Scanner;

//班级
public class JavaClass {
	String name;
	String dirTeacher, techTeacher;
	String beginDate;
	// 学员信息
	String[] mates = new String[30];

	// 查看班级信息
	public void showInfo() {
		System.out.println("班级" + name + ",指导老师" + techTeacher + "和" + dirTeacher);
		System.out.println("开班于" + beginDate);
		System.out.println("目前在读学员：");
		for (int i = 0; i < mates.length; i++) {
			if (mates[i] == null)
				break;
			System.out.print(mates[i] + "\t");
		}
		System.out.println();
	}

	// 增加新学员的方法
	public void add(String newStudent) {
		for (int i = 0; i < mates.length; i++) {
			if (mates[i] == null) {
				mates[i] = newStudent;
				return;
			}

		}
		System.out.println("位置满了");
	}

	public boolean search(String sname) {
		for (int i = 0; i < mates.length; i++) {
			if (mates[i] != null && mates[i].equals(sname)) {
				return true;
			}
		}
		return false;// 不在
	}

	/// outline
	// 按照范围查找学生在不在
	public boolean search1(String sname, int start, int end) {
		for (int i = start; i <= end && i < mates.length; i++) {
			if (mates[i] != null && mates[i].equals(sname)) {
				return true;
			}
		}
		return false;
	}
	// public void search() {
	// Scanner in = new Scanner(System.in);
	// System.out.println("你要找谁？");
	// String sname = in.next();
	// }
}
